//
//  SKHomeViewController.m
//  loveKangaroo
//
//  Created by SeeKool on 15/3/3.
//  Copyright (c) 2015年 SeeKool Inc. All rights reserved.
//

#import "SKHomeViewController.h"
#import "SKCreatNewViewController.h"

@interface SKHomeViewController ()

@end

@implementation SKHomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    //导航栏标题
    self.title = @"爱袋鼠";
    
    //添加广告
    [self initAdView];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(creatNewBtnOnClick) name:@"creatNewBtnOnClick" object:nil];
}
- (void)dealloc{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"creatNewBtnOnClick" object:nil];

}
- (void)creatNewBtnOnClick{
    SKCreatNewViewController *creatNewVc = [[SKCreatNewViewController alloc] init];
    [self.navigationController pushViewController:creatNewVc animated:YES];
}
- (void)initAdView{
    UIScrollView *advertisement = [[UIScrollView alloc] init];
    int adCount = 3;
    advertisement.frame = CGRectMake(0, 0, ScreenWidth, 120);
    advertisement.contentSize = CGSizeMake(adCount * ScreenWidth, 0);
    advertisement.backgroundColor = [UIColor yellowColor];
    advertisement.showsHorizontalScrollIndicator = NO;
    advertisement.showsVerticalScrollIndicator = NO;
    advertisement.pagingEnabled = YES;
    advertisement.bounces = NO;
    [self.view addSubview:advertisement];
    
    for (int i = 0; i < adCount; i++) {
        
        //拼接广告图片名
        NSString *adImageName = [NSString stringWithFormat:@"ad%d",i + 1];
        UIImageView *adIamgeView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:adImageName]];
        CGFloat adImageViewX = i * ScreenWidth;
        CGFloat adImageViewY = 0;
        CGFloat adImageViewW = ScreenWidth;
        CGFloat adImageViewH = 120;
        adIamgeView.frame = CGRectMake(adImageViewX, adImageViewY, adImageViewW, adImageViewH);
        
        [advertisement addSubview:adIamgeView];
    }
}


@end
